package zy.learn.demo.structuredstreaming.basic

import org.apache.log4j.{Level, Logger}
import org.apache.spark.sql.SparkSession

object DirectOutput {
  def main(args: Array[String]): Unit = {
    Logger.getLogger("org").setLevel(Level.WARN)

    val spark = SparkSession.builder()
      .master("local[2]")
      .appName("DirectOutput").getOrCreate()
    // 1.从数据源加载数据
    val lines = spark.readStream
      .format("socket")
      .option("host", "localhost")
      .option("port", 9999)
      .load()
    // 2. 输出
    val result = lines.writeStream
      .format("console")
      .outputMode("update")
      .start()


    result.awaitTermination()
  }
}
